package server.util;

import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
/*
封装迭代器,保证迭代过程中数据不被破坏
 */
/*
2023/1/27 该类内容全部写完,后续直接使用,无需修改
by cyl
 */
public class Enumerator<E> implements Enumeration<E> {
    private Iterator<E> iterator = null;
    public Enumerator(Iterator<E> iterator) {
        this.iterator = iterator;
    }
    public Enumerator(Collection<E> collection) {
        this(collection.iterator());
    }
    @Override
    public boolean hasMoreElements() {
        return iterator.hasNext();
    }

    @Override
    public E nextElement() {
        return iterator.next();
    }
}
